'''
draw circle 
'''
from  tkinter import *
import math
OX = 400
OY = 400
MAX_X = 800 
MAX_Y = 800 
SCALE_X = 80
SCALE_Y = 80

X_Fix=40
Y_Fix=40

def draw_point (canvas,x,y,r =1, c="black"):
    canvas.create_oval(x-r,y+r,x+r,y+r,fill=c,outline=c)

def draw_axes(canvas,OX,OY,width,height):
    #use canvas axis
    # (0,500) -> (800,500)
    # draw x axis
    point1 = (0+X_Fix,OY)
    point2 = (width-X_Fix,OY)
    canvas.create_line(point1,point2)
   
    draw_text_fix(canvas,point1,"({},{})".format(point1[0],point1[1]),False)
    draw_text_fix(canvas,point2,"({},{})".format(point2[0],point2[1]),False)
    # (400,0) -> (400,600)
    # draw y axis
   
    point1= (OX,0+Y_Fix)
    point2 = (OX,height-Y_Fix)
    canvas.create_line(point1,point2)
    draw_text_fix(canvas,point1,"({},{})".format(point1[0],point1[1]),False)
    draw_text_fix(canvas, point2,"({},{})".format(point2[0],point2[1]),False)


def plot(canvas,x,y):
    # axis convert 
    draw_point(canvas,SCALE_X*x+ OX,OY-SCALE_Y*y)
    
    """_summary_
    need_fix：是否使用坐标轴转换
    """
def draw_text_fix(canvas,point,text,need_fix=True):
    
    x,y=point
    fix_x=x
    fix_y=y
    fill_color="black"
    if(need_fix):
        fill_color="red"   
        fix_x= SCALE_X*x+ OX
        fix_y=OY-SCALE_Y*y
        
    canvas.create_text(fix_x,fix_y,text=text,fill=fill_color)


def draw_int(canvas):
   draw_axes(canvas,OX,OY,MAX_X,MAX_Y)
   draw_text_fix(canvas,(0,0),"(0,0)",TRUE)
    

